/*
https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/?envType=problem-list-v2&envId=AnEpLQwV
28. 找出字符串中第一个匹配项的下标
*/

class Solution {
public:
    int strStr(string haystack, string needle) {
        int i;
        for(int i=0;i<haystack.size();i++)
        {
            int j;
            for(j=0;j<needle.size();j++)
            {
               if(haystack[i+j]!=needle[j])
               break;
            }
            if(j==needle.size())
            return i;
        }
        return -1;
    }
};